using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class asp_pages_Login : System.Web.UI.Page
{
    PersonDAO daoPerson = new PersonDAO();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Validate();
        if (!IsValid) return;
        if (daoPerson.CheckAccount(txtUsername.Text, txtPassword.Text).ID > 0)
        {
            Session["logedin"] = true;
            Session["user"] = txtUsername.Text;
            FormsAuthentication.SetAuthCookie(txtUsername.Text, true);
            Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUsername.Text,true));
        }
        else lblMessage.Text = "Username or password is not correct. Please try again.";
        
    }
}
